<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="EmpresasListForm">

        <p:panel header="#{bundle.ListEmpresasTitle}">

            <p:dataTable id="datalist" value="#{empresasController.items}" var="item"
                         selectionMode="single" selection="#{empresasController.selected}"
                         rowKey="#{item.idEmpresas}"
                         paginator="true"
                         rows="10"
                         rowsPerPageTemplate="10,20,30"
                         >

                <p:ajax event="rowSelect"   update="createButton viewButton editButton deleteButton"/>
                <p:ajax event="rowUnselect" update="createButton viewButton editButton deleteButton"/>

                <p:column sortBy="#{item.idEmpresas}" filterBy="#{item.idEmpresas}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListEmpresasTitle_idEmpresas}"/>
                    </f:facet>
                    <h:outputText value="#{item.idEmpresas}"/>
                </p:column>
                <p:column sortBy="#{item.nombre}" filterBy="#{item.nombre}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListEmpresasTitle_nombre}"/>
                    </f:facet>
                    <h:outputText value="#{item.nombre}"/>
                </p:column>
                <p:column sortBy="#{item.nit}" filterBy="#{item.nit}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListEmpresasTitle_nit}"/>
                    </f:facet>
                    <h:outputText value="#{item.nit}"/>
                </p:column>
                <p:column sortBy="#{item.direccion}" filterBy="#{item.direccion}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListEmpresasTitle_direccion}"/>
                    </f:facet>
                    <h:outputText value="#{item.direccion}"/>
                </p:column>
                <p:column sortBy="#{item.telefono}" filterBy="#{item.telefono}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListEmpresasTitle_telefono}"/>
                    </f:facet>
                    <h:outputText value="#{item.telefono}"/>
                </p:column>
                <p:column sortBy="#{item.idEmpresarios.idEmpresarios}" filterBy="#{item.idEmpresarios.idEmpresarios}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListEmpresasTitle_idEmpresarios}"/>
                    </f:facet>
                    <h:outputText value="#{item.idEmpresarios.idEmpresarios}"/>
                </p:column>
                <f:facet name="footer">
                    <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{bundle.Create}" actionListener="#{empresasController.prepareCreate}" update=":EmpresasCreateForm" oncomplete="EmpresasCreateDialog.show()"/>
                    <p:commandButton id="viewButton"   icon="ui-icon-search" value="#{bundle.View}" update=":EmpresasViewForm" oncomplete="EmpresasViewDialog.show()" disabled="#{empty empresasController.selected}"/>
                    <p:commandButton id="editButton"   icon="ui-icon-pencil" value="#{bundle.Edit}" update=":EmpresasEditForm" oncomplete="EmpresasEditDialog.show()" disabled="#{empty empresasController.selected}"/>
                    <p:commandButton id="deleteButton" icon="ui-icon-trash"  value="#{bundle.Delete}" actionListener="#{empresasController.delete}" update=":growl,datalist" disabled="#{empty empresasController.selected}"/>
                </f:facet>

            </p:dataTable>

        </p:panel>

    </h:form>

</ui:composition>